/**
* +----------------------------------------------------------------------
* | 友得云客  - 开启房产营销新纪元
* +----------------------------------------------------------------------
* | Copyright (c) 2019~2023 优得（西安）信息科技有限公司版权所有
* +----------------------------------------------------------------------
* | Licensed 友得云客不是自由软件 未经允许不可移除相关版权
* +----------------------------------------------------------------------
* | Author: www.youdeyunke.com
* +----------------------------------------------------------------------
*/
import request from '@/utils/request'


export function getPageList () {
    return request({
        url: '/admin6/pages',
        method: 'get',
    })
}

export function getPageDetail (pageId) {
    return request({
        url: '/admin6/pages/' + pageId,
        method: 'get',
    })
}

export function updatePage (page, cmd) {
    return request({
        url: '/admin6/pages/' + page.id,
        method: 'PATCH',
        data: { page: page, cmd: cmd }
    })
}

export function updatePageName (page) {
    return request({
        url: '/admin6/pages/' + page.id,
        method: 'PATCH',
        data: { page: { name: page.name }, cmd: 'set_name' }
    })
}

export function clonePage (pageId) {
    return request({
        url: '/admin6/pages/' + pageId,
        method: 'PATCH',
        data: { cmd: 'clone_page' }
    })

}
//setHome用不到了
export function setHome (pageId) {
    return request({
        url: '/admin6/pages/' + pageId,
        method: 'PATCH',
        data: { cmd: 'set_home' }
    })

}

export function updatePageConfig (page) {
    return request({
        url: '/admin6/pages/' + page.id,
        method: 'PATCH',
        data: { page: { config: page.config }, cmd: 'set_config' }
    })
}

export function updatePageModules (page) {
    return request({
        url: '/admin6/pages/' + page.id,
        method: 'PATCH',
        data: { page: { modules: page.modules }, cmd: 'set_modules' }
    })
}

export function createPage (page) {
    return request({
        url: '/admin6/pages/',
        method: 'POST',
        data: page,
    })
}


export function deletePage (pageId) {
    return request({
        url: '/admin6/pages/' + pageId,
        method: 'DELETE'
    })
}


export function exportPage (keys) {
  return request({
    url: '/admin6/pages/export',
    method: 'POST',
    data: keys,
  })
}

export function importPage (file) {
  return request({
    url: '/admin6/pages/import',
    method: 'POST',
    data: file,
  })
}

export  function getPageFileKes(file){
  return request({
    url: '/admin6/pages/get_keys',
    method: 'POST',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: file
  })
}

export function updatePageRules (id, data) {
    return request({
        url: '/admin6/pages/rules/' + id,
        method: 'PATCH',
        data: {
            rules: data
        }
    })
}